package services

import (
	"short-video/rpc/global"
	"short-video/rpc/models/dao"
)

func CrateUser(user dao.User) error {
	return global.Db.Create(&user).Error
}

func QueryUserByMobile(mobile string) (user dao.User, err error) {
	err = global.Db.Where("mobile = ?", mobile).First(&user).Error
	return user, err
}

func CrateHomePage(page dao.HomePage) error {
	return global.Db.Create(&page).Error
}

func QueryUserInfoByName(name string) (page []dao.HomePage, err error) {
	err = global.Db.Where("name = ?", name).First(&page).Error
	return page, err
}

func CrateWorks(works dao.Works) error {
	return global.Db.Create(&works).Error
}

func QueryWorksInfoByTitle(title string) (works []dao.Works, err error) {
	err = global.Db.Where("title = ?", title).First(&works).Error
	return works, err
}
func CrateGiveThumbsUp(up dao.GiveThumbsUp) error {
	return global.Db.Create(&up).Error
}

func DeletedGiveThumbsUp(id int) error {
	var GiveThumbsUp dao.GiveThumbsUp
	return global.Db.Where("id = ?", id).Delete(&GiveThumbsUp).Error
}

func CreateDiscuss(discuss dao.Discuss) error {
	return global.Db.Create(&discuss).Error
}
